package com.zd.web.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.zd.entity.Novel;
import com.zd.entity.Writer;
import com.zd.service.WriterService;
import com.zd.service.impl.WriterServiceImpl;

/**
 * Servlet implementation class WriterCenterServlet
 */
@WebServlet("/WriterCenterServlet")
public class WriterCenterServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public WriterCenterServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		request.setCharacterEncoding("UTF-8");
		response.setCharacterEncoding("UTF-8");
		Writer w=(Writer)request.getSession().getAttribute("writer");
		if(w==null) {
			System.out.println("没有登录");
			return;
		}
		int writerid=w.getWriterId();
		WriterService writerservice=new WriterServiceImpl();
		List<Novel> list=writerservice.writerym(writerid);
		List<Writer> list1=writerservice.writerinformation(writerid);
		int novelnum=writerservice.novelnum(writerid);
		int contentnum=writerservice.contentnum(writerid);
//		System.out.println(novelnum);
//		System.out.println(contentnum);
		request.setAttribute("list", list);
		request.setAttribute("list1", list1);
		request.setAttribute("novelnum", novelnum);
		request.setAttribute("contentnum", contentnum);
		request.getRequestDispatcher("writeradmin.jsp").forward(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
